/**
 * @author Adam
 * 	this is the Execution Leader Panel 
 */

package gui;

import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.ArrayList;

public class ExecutionLeaderPanel extends JPanel {
	private	AcademicFrame frame;
	private	AssessorPanel assessor;
	private	MainWindow mainWindow;
	private	ExecutionLeaderPanel myself;
	private ExecutePanel execute;
	private	SetExecutionDuration ex2;
	private	String pid;
	private	String currentStatus;
	private String Elid;
	private String table;
	private ArrayList<Object> listofExecutionRequests;
	
	public ExecutionLeaderPanel(AcademicFrame frame, MainWindow mainWindow,String pid) {
		super();
		this.frame=frame;
		this.mainWindow=mainWindow;
		this.pid=pid;
		this.myself=this;
		frame.setSize(500, 400);
		initialize();
	}
	
	private void initialize() {
		setLayout(null);
		
		JLabel lblExecutionLeader = new JLabel("Execution Leader");
		lblExecutionLeader.setForeground(Color.BLUE);
		lblExecutionLeader.setFont(new Font("Tahoma", Font.BOLD, 28));
		lblExecutionLeader.setBounds(103, 32, 244, 26);
		add(lblExecutionLeader);
		
		JButton btnSetExecutionDuration = new JButton("Set Execution Duration");
		btnSetExecutionDuration.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				currentStatus="8";
				Elid="Elid";
				table="request";
				ex2= new SetExecutionDuration(frame,myself,pid);
				listofExecutionRequests = new ArrayList<Object>();
				listofExecutionRequests.add("getlistOfExRequests");
				listofExecutionRequests.add(pid);
				listofExecutionRequests.add(currentStatus);
				listofExecutionRequests.add(Elid);
				listofExecutionRequests.add(table);
				
				AcademicFrame.myclient.sendMessageToServer(listofExecutionRequests); // get list of systems
				frame.setSize(500, 500);
				frame.setContentPane(ex2);
			}
		});
		btnSetExecutionDuration.setBounds(65, 112, 143, 23);
		add(btnSetExecutionDuration);
		JButton btnExecution = new JButton("Execution");
		btnExecution.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				currentStatus="10";
				Elid="Elid";
				table="request";
				 execute = new ExecutePanel(frame, myself, pid);
				 listofExecutionRequests = new ArrayList<Object>();
					listofExecutionRequests.add("getlistOfExRequests");
					listofExecutionRequests.add(pid);
					listofExecutionRequests.add(currentStatus);
					listofExecutionRequests.add(Elid);
					listofExecutionRequests.add(table);
					AcademicFrame.myclient.sendMessageToServer(listofExecutionRequests); // get list of systems
					frame.setSize(500, 499);
					frame.setContentPane(execute);
			}
		});
		btnExecution.setBounds(252, 112, 143, 23);
		add(btnExecution);
		
		JButton btnBack = new JButton("Back");
		btnBack.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frame.setSize(500, 500);
				frame.setContentPane(mainWindow);
			}
		});
		btnBack.setBounds(184, 238, 89, 23);
		add(btnBack);
	}

}
